#include<iostream>//链表分块查找
#include<cstdio>
#include<cstring>
using namespace std;
int list_a[100]={2,1,4,11,22,33,111,222,333,456,789};
struct Block_list
{
    int value_list[20];
    int top=0;
    int max_value=0;
    int start_id;
}blist[11];
class Linked_list
{
    public:
        Linked_list();
        void virtual li_insert(int x);
        void li_delete(int id);
        void virtual li_print();
    private:
        struct node
        {
            int value;
            node *next;
        }*start;
};
Linked_list::Linked_list()
{
    this->start=(node *)malloc(sizeof(node));
    this->start->next=NULL;
    this->start->value=-1;
}
void Linked_list::li_insert(int x)
{
    node *p=this->start;
    while(p->next!=NULL)
    {
        p=p->next;
    }
    node *new_node=(node *)malloc(sizeof(node));
    new_node->value=x;
    p->next=new_node;
}
void Linked_list::li_delete(int id)
{
    int cnt=0;node *p=this->start,*q;
    while(p!=NULL)
    {
        q=p;
        p=p->next;
        cnt++;
        if(cnt==id&&p!=NULL){
            q->next=p->next;
            free(p);
            break;
        }
    }
    if(p==NULL)
    {
        printf("Out Value!\n");return;
    }
    else printf("Sueecss!\n");
}
void Linked_list::li_print()
{
    node  *p=this->start;
    while(p!=NULL)
    {
        p=p->next;
        if(p!=NULL)
            cout<<p->value<<' ';
    }
}
class New_Linked_list: public Linked_list
{
    private:
        struct node
        {
            Block_list list_value;
            node *next;
        }*start1;
    public:
        New_Linked_list()
        {
            start1=(node*)malloc(sizeof(node));
            start1->next=NULL;
        }
        void li_insert(Block_list x);
        int li_find(int x);
};
void New_Linked_list::li_insert(Block_list x)
{
    node *p=this->start1;
    while(p->next!=NULL)
    {
        p=p->next;
    }
    node *new_node=(node *)malloc(sizeof(node));
    new_node->list_value=x;
    p->next=new_node;
}
int New_Linked_list::li_find(int x)
{
    node *p=this->start1->next;
    while(p!=NULL)
    {
        if(x<=p->list_value.max_value)break;
        p=p->next;
    }
    Block_list now=p->list_value;
    for(int i=1;i<=now.top;i++)
    {
        if(now.value_list[i]==x)return ((i-1)+now.start_id);
    }
    return -1;
}
int main()
{
    int n=11;
    int j=1;
    New_Linked_list L;
    for(int i=0;i<n;i++)
    {
        blist[j].value_list[++blist[j].top]=list_a[i];
        if(list_a[i]>blist[j].max_value)blist[j].max_value=list_a[i];
        if(blist[j].top==3)
        {
            j++;blist[j].max_value=0;blist[j].start_id=i;
        }
    }
    for(int i=1;i<=j;i++)
    {
        L.li_insert(blist[i]);
    }
    int ans=L.li_find(222);
    if(ans==-1)cout<<"Not Find!"<<endl;
    else cout<<ans<<endl;
    return 0;
}